﻿using Gds.Model.ConfigModel.Controller;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gds.Model.ConfigModel.CommuEquip
{
    /// <summary>
    /// 各种不同厂家类型设备通讯的接口
    /// </summary>
    public  interface IcommuTool
    {
        string MainAddress { get; set; }
        string ControlCode { get; set; }
        string TotalLineNumber { get; set; }
        int ItemLenth { get; set; }
        string ItemValue { get; set; }
        string CalaValue { get; set; }
        bool WriteDataFlag { get; set; }
        /// <summary>
        /// 停止通讯标志 故障 或者被 屏蔽了
        /// </summary>
        bool StopSend { get; set; }
        bool RetrunEmpty { get; set; }
        Utility.Helper.SerialHelper SerialHelper { get; set; }
        void AnalyzeCode(string Code, int startIndex);
        string CRC16Calc(string sendD);
        bool ReadControllerData(TaskControllerModel _controller);
        bool ReadGasValueAndState(Model.ConfigModel.GasMeter.TaskGasMeterModel _controllerList);
        void Get_keepingChannalInfoList();
        void Get_inputChannalInfoList(Dictionary<int,GasMeter.TaskGasMeterModel> _gasMeterList);
        /// <summary>
        /// 复位
        /// </summary>
        /// <param name="_controller"></param>
        /// <returns></returns>
        bool Set_GasMeterReSet(TaskControllerModel _controller);
        /// <summary>
        /// 消音
        /// </summary>
        /// <param name="_controller"></param>
        /// <returns></returns>
        bool Set_GasMeterNoVoice(TaskControllerModel _controller);
        void AddLog(string msg);
        Dictionary<int, GasMeter.GasSaveModel> realTimeValue{get;set;}
        Dictionary<int,GasMeter.GasSaveModel> lastTimerealTimeValue{get;set; }
        /// <summary>
        /// 保持寄存器值
        /// </summary>
        Dictionary<int, string> KeepingDic { get; set; }
        /// <summary>
        /// 输入寄存器值
        /// </summary>
        Dictionary<int, string> InputDic { get; set; }
        /// <summary>
        /// 每个通道需要占位多少个寄存器
        /// </summary>
        int ChannelDataLength { get; set; }
        /// <summary>
        /// 通讯读取开始地址
        /// </summary>
        int StartIndex { get; set; }
        /// <summary>
        /// 每次读取长度
        /// </summary>
        int ReadLength { get; set; }
        /// <summary>
        /// 需要读取的数据总长度
        /// </summary>
        int NeedReadLength { get; set; }
        /// <summary>
        /// 发送指令列表
        /// </summary>
        List<string> SendCodeList { get; set; }
        bool IsFinishSendData { get; set; }
        bool CanCommunication { get; set; }
        bool IsSendNoVice { get; set; }
        bool IsSendReset { get; set; }
        bool IsSendNoViceResult { get; set; }
        bool IsSendResetResult { get; set; }
        /// <summary>
        /// 是否支持消音复位
        /// </summary>
        bool IsCanSet { get; set; }
        /// <summary>
        /// 当前控制器通讯失败次数
        /// </summary>
        int ControllerFailTime { get; set; }
        /// <summary>
        /// 控制器连续通讯失败最大次数
        /// </summary>
        int ControllerFailMaxTime { get; set; }
        /// <summary>
        /// 输入日志事件
        /// </summary>
        event EventHandler AddLogEventHandler;
        /// <summary>
        /// 输入错误日志事件
        /// </summary>
        event EventHandler AddErrorLogEventHandler;
        /// <summary>
        /// 添加运行状态事件
        /// </summary>
        event EventHandler AddRunStateModelEventHandler;

    }
}
